#include "task_test.h"
// rtos
#include "FreeRTOS.h"
// #include "event_groups.h"
// #include "semphr.h"
// #include "task.h"
#include "timers.h"
// lib
#include <string.h>
#include <stdlib.h>
#include "debug.h"
// bsp
#include "bsp_led_ctrl.h"
#include "bsp_MAX44009.h"
#include "bsp_gt911.h"
// msp
#include "msp_gpio.h"
#include "sw_iic.h"
#include "sw_i2c.h"
// app
#include "debug.h"

// RTOS基础测试
// void App_Application_Test(void)
void App_Application_Test_t1(void)
{
    while (1)
    {
        _DEBUG_PRINT(DBG_STP, "test\r\n");
        vTaskDelay(1000);
        // delay_us(100000);// 测试通过
    }
}

// IIC通信测试-简单通信测试
// void App_Application_Test(void)
void App_Application_Test_t2_1(void)
{
    uint32_t max44009_data_array[10] = {0};
    MAX44009_Configuration();
    while (1)
    {
        Period_MAX44009_Data_Collection(max44009_data_array);
        _DEBUG_PRINTF(DBG_STP, "max44009_data_array data:\r\n");
        printf("%s\r\n", (char *)max44009_data_array);
        _DEBUG_PRINT(DBG_STP, "Hex data:\r\n");
        Printf_String_In_Hex((uint8_t *)max44009_data_array, 10*sizeof(uint32_t));
        vTaskDelay(5000);
    }
}

// IIC通信测试-所有IO测试
// void App_Application_Test(void)
void App_Application_Test_t2_2(void)
{
    uint8_t  ret = 0;
    #if 0
    SW_IIC_Init();
    SW_IIC_SDA_OUT();
    SW_IIC_SCL_SET(0);
    SW_IIC_SDA_SET(0);
    vTaskDelay(10);
    SW_IIC_SCL_SET(1);
    SW_IIC_SDA_SET(1);
    vTaskDelay(10);
    SW_IIC_SCL_SET(0);
    SW_IIC_SDA_SET(0);
    vTaskDelay(10);
    SW_IIC_SDA_IN();
    SW_IIC_SDA_OUT();
    SW_IIC_SCL_SET(1);
    SW_IIC_SDA_SET(1);
    vTaskDelay(10);
    while (1) vTaskDelay(1000);
    #endif
    #if 0
    SW_IIC_Init();
    SW_IIC_SDA_IN();
    while (1)
    {
        ret = SW_IIC_SDA_GRT_STATE();
        _DEBUG_PRINTF(DBG_STP, "SDA(B0) input = %d\r\n", ret);
        vTaskDelay(1000);
    }
    #endif
    #if 1
    GT911_Init();
    GT911_RST_SET(1);
    GT911_RST_SET(0);
    GT911_RST_SET(1);
    GT911_RST_SET(0);
    GT911_RST_SET(1);
    while (1)
    {
        ret = GT911_INT_STATE();
        _DEBUG_PRINTF(DBG_STP, "GT911_INT(B10) input = %d\r\n", ret);
        vTaskDelay(1000);
    }
    #endif
}

// IIC通信测试-实际测试
void App_Application_Test(void)
// void App_Application_Test_t2_3(void)
{
    uint8_t  ret = 0;
    while (GT911_Init())
    {
        _DEBUG_PRINT(DBG_STP, "GT911 Init...\r\n");
        vTaskDelay(1000);
    }
    while (1)
    {
        ret = GT911_Scan(0);
        _DEBUG_PRINTF(DBG_STP, "GT911 Scan ret = %d\r\n", ret);
        vTaskDelay(10);
    }
}


